import { lib, game, ui, get, ai, _status } from "../../noname.js";
import standard from "./character/standard.js";
import isotope from "./character/isotope.js";
import SP from "./character/SP.js";
import outStory from "./character/outStory.js";
import reacgn from "./character/reacgn.js";

/**
 * 子包列表
 */
const packList = [
    standard,   //十质点
    isotope,    //反转体
    SP,         //异构体
    outStory,   //别传
    reacgn,     //ACGN
];
// const packList = [
//     require('./character/standard.js'),     //十质点
//     require('./character/isotope.js'),      //反转体
//     require('./character/SP.js'),           //异构体
//     require('./character/outStory.js'),     //别传
// ];

/**
 * 将子包列表中成员的指定子对象拼接为对象
 * @param {String} key 指定子对象键名
 * @returns {Object} 由指定子对象组成的对象
 */
function memberToString(key) {
    let str = '';
    for (let i = 0; i < packList.length; i++) {
        if (packList[i][key])
            str += `...packList[${i}].${key},`;
    }
    return eval('({' + str.slice(0, -1) + '})');
}

/**
 * 子包分包处理
 */
const subpackSort = {}
for (const i of packList) {
    const name = i.name;
    subpackSort[name] = Object.keys(i.character);
}

/**
 * 原始的武将包
 */
const packs = {
    name: "DALF",
    connect: true,
    // connectBanned: [],
    character: memberToString('character'),
    characterSort: {
        DALF: subpackSort,
    },
    // characterFilter: {},
    characterTitle: memberToString('characterTitle'),
    dynamicTranslate: memberToString('dynamicTranslate'),
    characterIntro: memberToString('characterIntro'),
    // characterReplace: {},
    card: memberToString('card'),
    skill: memberToString('skill'),
    translate: memberToString('translate')
}

/**
 * 武将插画处理
 */
if (lib.device || lib.node) {
    for (var i in packs.character) {
        packs.character[i][4].push(`ext:约会大作战/image/character/${i}.jpg`);
    }
} else {
    for (var i in packs.character) {
        packs.character[i][4].push(`db:extension-约会大作战-image-character:${i}.jpg`);
    }
}

/**
 * 武将配音依照设置禁用或启用
 */
if (!lib.config.extension_约会大作战_skill_audio) {
    for (var i in packs.skill) {
        delete packs.skill[i].audio;
    }
}

/**
 * 向游戏内加入武将包
 */
game.import("character", function () {
    return packs;
});
if (!lib.config.characters.includes('DALF')) lib.config.characters.push('DALF');
lib.translate['DALF_character_config'] = '约会大作战';